<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of v_lpcra2ar</title>
  <meta name="keywords" content="v_lpcra2ar">
  <meta name="description" content="V_LPCRA2AR Convert inverse filter autocorrelation coefs to AR filter. AR=(RA)">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">v_mfiles</a> &gt; v_lpcra2ar.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for v_mfiles&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>v_lpcra2ar
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>V_LPCRA2AR Convert inverse filter autocorrelation coefs to AR filter. AR=(RA)</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function ar=v_lpcra2ar(ra,tol) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment">V_LPCRA2AR Convert inverse filter autocorrelation coefs to AR filter. AR=(RA)

 Usage: (1) ar0=poly([0.5 0.2]);  % ar0=[1 -0.7 0.1]
            ra0=v_lpcar2ra(ar0);    % ra0=[1.5 -0.77 0.1]
            ar1=v_lpcra2ar(ra0);    % ar1 = ar0

        (2) ar0=poly([0.5 0.2]);                   % ar0=[1 -0.7 0.1]
            arx=xcorr(ar0);                        % arx=[0.1 -0.77 1.5 -0.77 0.1]
            ar1=v_lpcra2ar(arx(length(ar0):end));    % ar1 = ar0

  Inputs: ra(n,p+1) each row is the second half of the autocorrelation of
                    the coefficients of a stable AR filter of order p
          tol       tolerance relative to ra(1) [1e-8]

 Outputs: ar(n,p+1) each row gives coefficients of an AR filter of order p

 This routine uses a Newton-Raphson iteration described in [1] to invert
 the cross-correlation function (as in the second usage example above).

 Refs:
 [1]  G. Wilson. Factorization of the covariance generating function of a pure moving average process.
      SIAM Journal on Numerical Analysis, 6 (1): 1�7, 1969.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function ar=v_lpcra2ar(ra,tol)</a>
0002 <span class="comment">%V_LPCRA2AR Convert inverse filter autocorrelation coefs to AR filter. AR=(RA)</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% Usage: (1) ar0=poly([0.5 0.2]);  % ar0=[1 -0.7 0.1]</span>
0005 <span class="comment">%            ra0=v_lpcar2ra(ar0);    % ra0=[1.5 -0.77 0.1]</span>
0006 <span class="comment">%            ar1=v_lpcra2ar(ra0);    % ar1 = ar0</span>
0007 <span class="comment">%</span>
0008 <span class="comment">%        (2) ar0=poly([0.5 0.2]);                   % ar0=[1 -0.7 0.1]</span>
0009 <span class="comment">%            arx=xcorr(ar0);                        % arx=[0.1 -0.77 1.5 -0.77 0.1]</span>
0010 <span class="comment">%            ar1=v_lpcra2ar(arx(length(ar0):end));    % ar1 = ar0</span>
0011 <span class="comment">%</span>
0012 <span class="comment">%  Inputs: ra(n,p+1) each row is the second half of the autocorrelation of</span>
0013 <span class="comment">%                    the coefficients of a stable AR filter of order p</span>
0014 <span class="comment">%          tol       tolerance relative to ra(1) [1e-8]</span>
0015 <span class="comment">%</span>
0016 <span class="comment">% Outputs: ar(n,p+1) each row gives coefficients of an AR filter of order p</span>
0017 <span class="comment">%</span>
0018 <span class="comment">% This routine uses a Newton-Raphson iteration described in [1] to invert</span>
0019 <span class="comment">% the cross-correlation function (as in the second usage example above).</span>
0020 <span class="comment">%</span>
0021 <span class="comment">% Refs:</span>
0022 <span class="comment">% [1]  G. Wilson. Factorization of the covariance generating function of a pure moving average process.</span>
0023 <span class="comment">%      SIAM Journal on Numerical Analysis, 6 (1): 1�7, 1969.</span>
0024 
0025 <span class="comment">%      Copyright (C) Mike Brookes 2015</span>
0026 <span class="comment">%      Version: $Id: v_lpcra2ar.m 10865 2018-09-21 17:22:45Z dmb $</span>
0027 <span class="comment">%</span>
0028 <span class="comment">%   VOICEBOX is a MATLAB toolbox for speech processing.</span>
0029 <span class="comment">%   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html</span>
0030 <span class="comment">%</span>
0031 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
0032 <span class="comment">%   This program is free software; you can redistribute it and/or modify</span>
0033 <span class="comment">%   it under the terms of the GNU General Public License as published by</span>
0034 <span class="comment">%   the Free Software Foundation; either version 2 of the License, or</span>
0035 <span class="comment">%   (at your option) any later version.</span>
0036 <span class="comment">%</span>
0037 <span class="comment">%   This program is distributed in the hope that it will be useful,</span>
0038 <span class="comment">%   but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
0039 <span class="comment">%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
0040 <span class="comment">%   GNU General Public License for more details.</span>
0041 <span class="comment">%</span>
0042 <span class="comment">%   You can obtain a copy of the GNU General Public License from</span>
0043 <span class="comment">%   http://www.gnu.org/copyleft/gpl.html or by writing to</span>
0044 <span class="comment">%   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.</span>
0045 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
0046 <span class="keyword">persistent</span> p0 i1 i2 j1 j2
0047 <span class="keyword">if</span> nargin&lt;2
0048     tol=1e-8;  <span class="comment">% tolerance in ra/ra(1)</span>
0049 <span class="keyword">end</span>
0050 imax=20;
0051 [nf,pp]=size(ra);
0052 <span class="keyword">if</span> ~numel(p0) || p0~=pp <span class="comment">% create index lists for hankel and toeplitz matrices</span>
0053     p0=pp;
0054     ix=zeros(1,(pp)*(pp+1)/2);
0055     nn=1:pp;
0056     ix(1+(nn-1).*nn/2)=1;
0057     j1=cumsum(ix);
0058     i1=cumsum(pp-1+(j1*(1-pp)+pp).*ix)-pp+1;
0059     j2=pp+1-j1;
0060     i2=cumsum(((pp+1)*j1-1).*ix-pp-1)+pp+1;
0061 <span class="keyword">end</span>
0062 ar=zeros(nf,pp);    <span class="comment">% space for output filter coefficients</span>
0063 t1=zeros(pp,pp);    <span class="comment">% space for hankel coefficient matrix</span>
0064 t2=t1;              <span class="comment">% space for toeplitz lower triangular coefficient matrix</span>
0065 ax0=zeros(1,pp);    <span class="comment">% temporary filter coefficient row vector</span>
0066 <span class="keyword">for</span> n=1:nf          <span class="comment">% process the input matrix one row at a time</span>
0067     xa=ra(n,:);     <span class="comment">% pick out row n</span>
0068     ax=ax0;         <span class="comment">% initialize ax to have all roots at zero</span>
0069     ax(1)=sqrt(xa(1)+2*sum(xa(2:end)));
0070     i=imax;         <span class="comment">% maximum number of iterations</span>
0071     <span class="keyword">while</span>(i&gt;0)
0072         t1(i1)=ax(j1); <span class="comment">% t1=hankel(ax)</span>
0073         t2(i2)=ax(j2); <span class="comment">% t2=toeplitz(ax,[ax(1) zeros(1,p)])</span>
0074         ct=ax*t1;
0075         ax=(xa+ct)/(t1+t2);
0076         i=min(i-1,i*(max(abs(ct-xa))&gt;tol*xa(1))+1); <span class="comment">% do one final iteration after tolerance reached</span>
0077     <span class="keyword">end</span>
0078     ar(n,:)=ax;
0079 <span class="keyword">end</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>